package org.example.javaweb.service.admin;

import org.example.javaweb.entity.User;
import org.example.javaweb.repository.admin.UserManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserManagementServiceImpl implements UserManagementService {

    @Autowired
    private UserManagement userManagement;

    @Override
    public boolean addUser(User user) {
        int num = userManagement.addUser(user);
        System.out.println(num);
        if (num > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean updateUser(User user) {
        int num = userManagement.updateUser(user);
        if (num > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteUser(User user) {
        int num = userManagement.deleteUser(user);
        if(num > 0) {
            return true;
        }
        return false;
    }

    @Override
    public User findUserById(User user) {
        return userManagement.findUserById(user);
    }

    @Override
    public User findUserByName(User user) {
        return userManagement.findUserByName(user);
    }

    @Override
    public List<User> findAllUsers() {
        return userManagement.findAllUsers();
    }
}
